package com.zhou.listener.listener;

import com.zhou.listener.MyBean;
import com.zhou.listener.library.listener.BaseDownloadListener;
import com.zhou.listener.MyAdapter;

public class MyAdapterListener extends BaseDownloadListener<MyBean,MyAdapter.ViewHolder> {


    public MyAdapterListener(MyAdapter.ViewHolder vh) {
        super(vh);
    }

    @Override
    public void onPending() {
        if(mVH.get()!=null){
            mVH.get().name.setText("等待中");
        }
    }

    @Override
    public void onPause(long soFarBytes, long totalBytes) {
        if(mVH.get()!=null){
            mVH.get().name.setText("暂停中");
        }
    }

    @Override
    public void onProgress(long soFarBytes, long totalBytes) {
        if(mVH.get()!=null){
            mVH.get().name.setText("进行中 "+soFarBytes+"/"+totalBytes);
        }
        //
    }

    @Override
    public void onError() {
        if(mVH.get()!=null){
            mVH.get().name.setText("下载错误");
        }
    }

    @Override
    public void onCompleted() {
        if(mVH.get()!=null){
            mVH.get().name.setText("下载完成");
        }
    }

    @Override
    public void initState(int state) {
        if(state==0){
            if(mVH.get()!=null){
                mVH.get().name.setText("未开始");
            }
        }else if (state==1){
            if(mVH.get()!=null){
                mVH.get().name.setText("等待中");
            }
        }
    }
}
